package se.wangs.decorator.abstracttype;

import org.junit.Test;
import se.wangs.decorator.abstracttype.beverages.DarkRoast;
import se.wangs.decorator.abstracttype.beverages.Espresso;
import se.wangs.decorator.abstracttype.beverages.HouseBlend;
import se.wangs.decorator.abstracttype.decorators.Mocha;
import se.wangs.decorator.abstracttype.decorators.Soy;
import se.wangs.decorator.abstracttype.decorators.Whip;

/**
 * -- coding: UTF-8 -- *
 *
 * @author wangs
 * @date 2023/12/11 15:38
 * @description 测试使用抽象类实现装饰器模式
 */
public class AbstractTest {
    @Test
    public void test() {
        Beverage beverage = new Espresso();
        System.out.println(beverage.getName() + " $" + beverage.cost());

        Beverage beverage1 = new DarkRoast();
        beverage1 = new Mocha(beverage1);
        beverage1 = new Mocha(beverage1);
        beverage1 = new Whip(beverage1);
        System.out.println(beverage1.getName() + " $" + beverage1.cost());

        Beverage beverage2 = new HouseBlend();
        beverage2 = new Soy(beverage2);
        beverage2 = new Mocha(beverage2);
        beverage2 = new Whip(beverage2);
        System.out.println(beverage2.getName() + " $" + beverage2.cost());

    }
}
